/*
 * LDIR
 * 
 * LDIR, a GPS cartography application built for Let's Do It Romania eco 
 * campaign.
 * Copyright (C) 2010 Genera Software <office@generasoftware.com>
 * 
 * http://generasoftware.com/
 * 
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Suite 330, Boston, MA 02111-1307 USA
 */
#ifndef		__HTTPFILTER_H__
#define		__HTTPFILTER_H__

#include <e32std.h>
#include <e32base.h>
#include <http/mhttpfilter.h>
#include <http/rhttpsession.h>

class CHttpFilter : public CBase, public MHTTPFilter
    {
public:
    // Constructor
     CHttpFilter();

    void ConstructL(RHTTPSession& aSession);

    ~CHttpFilter();

public:	// Methods from MHTTPFilterBase

    /// @see MHTTPFilterBase::MHFRunL
    virtual void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent);

    /// @see MHTTPFilterBase::MHFSessionRunL
    virtual void MHFSessionRunL(const THTTPSessionEvent& aEvent);

    /// @see MHTTPFilterBase::MHFRunError
    virtual TInt MHFRunError(TInt aError, RHTTPTransaction aTransaction,
                             const THTTPEvent& aEvent);

    /// @see MHTTPFilterBase::MHFSessionRunError
    virtual TInt MHFSessionRunError(TInt aError, const THTTPSessionEvent& aEvent);

public:	// Methods from MHTTPFilter

    /// @see MHTTPFilter::MHFUnload
    virtual void MHFUnload(RHTTPSession aSession, THTTPFilterHandle aHandle);

    /// @see MHTTPFilter::MHFLoad
    virtual void MHFLoad(RHTTPSession aSession, THTTPFilterHandle aHandle);

private:

    void ValidateRequestMethodL(RHTTPTransaction aTransaction);

    TBool ValidateRequestHeadersL(RHTTPTransaction aTransaction);

    void ValidateRequestGetL(RHTTPTransaction aTransaction);

    void ValidateRequestPostL(RHTTPTransaction aTransaction);

    void ValidateRequestPutL(RHTTPTransaction aTransaction);

    void ValidateRequestTraceL(RHTTPTransaction aTransaction);

    void ValidateRequestHeadL(RHTTPTransaction aTransaction);

    void ValidateRequestOptionsL(RHTTPTransaction aTransaction);


    TBool ValidateResponseStatusCode(RHTTPTransaction aTransaction);


    TBool RequestFailIfContainsBodyL(RHTTPTransaction aTransaction);

    void FailAndCancelL(RHTTPTransaction aTransaction, THTTPEvent aStatus);


private:

    TBool iTransactionFailed;

    RHTTPMessage iCurrentMessage;

    RStringPool iStringPool;
    };


#endif // 	__HTTPFILTER_H__
